 <?php 

class FeedbackHandler{

private $subgr;
private $cat;
private $by;
private $cmon;
private $cyr;

private $con;

public function setSubgr($sub){

$this->subgr=$sub;

}

public function setCat($catt){

$this->cat=$catt;
}


public function setBy($byy){

$this->by=$byy; 
}


public function setCmon($cmon){

$this->cmon=$cmon; 
}

public function setCyr($cyr){

$this->cyr=$cyr; 
}



public function setCon($conn){

$this->con=$conn; 

}




public function feedbackAdd($subgr,$rel,$cdy,$com,$feed)
{

$sql="insert into feedback (sub_gr,related,com_date,com_by,feedback) values('$subgr','$rel','$cdy','$com','$feed')";

mysql_query($sql,$this->con) or die(mysql_error());

$msg="Succussfully Added";

return $msg;

}


public function getPageSearch($startrow,$limit){


$sql="select feedback.feedback_id,subject_code.subject,subject_code.grade,feedback.related,feedback.com_date from feedback,subject_code where feedback.sub_gr=subject_code.sub_gr order by feedback_id desc  Limit $startrow,$limit";

$result= mysql_query($sql,$this->con)or die(mysql_error()); 
return $result;

}


public function getSearch($startrow,$limit){

$x=new Dbconnect();

$con=$x->getConnection();

$sql="select feedback.feedback_id,subject_code.subject,subject_code.grade,feedback.related,feedback.com_date from feedback,subject_code where feedback.sub_gr=subject_code.sub_gr and feedback.sub_gr='$this->subgr' and feedback.related='$this->cat' and feedback.com_by='$this->by' and year(feedback.com_date)='$this->cyr' and month(feedback.com_date)='$this->cmon' order by feedback_id desc Limit $startrow,$limit";

$result1= mysql_query($sql,$this->con)or die(mysql_error()); 
return $result1;

 

}

public function getPaginationRow(){



$sql="select feedback.feedback_id,subject_code.subject,subject_code.grade,feedback.related,feedback.com_date from feedback,subject_code where feedback.sub_gr=subject_code.sub_gr and feedback.sub_gr='$this->subgr' and feedback.related='$this->cat' and feedback.com_by='$this->by' and year(feedback.com_date)='$this->cyr' and month(feedback.com_date)='$this->cmon' order by feedback_id desc ";

$result= mysql_query($sql,$this->con)or die(mysql_error()); 
return $result;

}


public function getDelete($id){

$sql="DELETE FROM feedback WHERE feedback_id='$id'";
mysql_query($sql,$this->con);

$msgd="Deleted";
return $msgd;
}




public function feedbackUpdate($id,$subgr,$rel,$cdy,$com,$feed){

$sql="update feedback set sub_gr='$subgr',related='$rel',com_date='$cdy',com_by='$com',feedback='$feed' where feedback_id='$id'";
mysql_query($sql,$this->con) or 
die(mysql_error());

$msg ="Record Successfully updated";

return $msg;	


}









}

?>